<template>
  <el-slider
    v-model="sliderValue"
    v-bind="$attrs"
    :min="min"
    :max="max"
    :step="step"
    :show-stops="showStops"
    :show-tooltip="showTooltip"
    :size="size"
    :disabled="disabled"
    :range="range"
    :vertical="vertical"
    :height="height"
    @change="handleChange"
    @input="handleInput"
  />
</template>

<script setup>
import { computed } from 'vue'
import { ElSlider } from 'element-plus'

const props = defineProps({
  modelValue: [Number, Array],
  min: {
    type: Number,
    default: 0
  },
  max: {
    type: Number,
    default: 100
  },
  step: {
    type: Number,
    default: 1
  },
  showStops: Boolean,
  showTooltip: {
    type: Boolean,
    default: true
  },
  size: String,
  disabled: Boolean,
  range: Boolean,
  vertical: Boolean,
  height: String
})

const emit = defineEmits(['update:modelValue', 'change', 'input'])

const sliderValue = computed({
  get() {
    return props.modelValue
  },
  set(value) {
    emit('update:modelValue', value)
  }
})

const handleChange = (value) => {
  emit('change', value)
}

const handleInput = (value) => {
  emit('input', value)
}
</script>